import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:liuxlcommon/view/extension_widget.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:liuxlcommon/view/my_style.dart';
import 'package:love_newf/generated/assets.dart';
import 'package:love_newf/value/app_colors.dart';

class LoginInputWeiget extends StatefulWidget {
  LInputType type;
  String text;
  String? hintText;
  String? leftText;
  String? leftAssets;
  int? flex;
  double? width;
  double? height;
  double? radius;
  int? maxLength;
  ValueChanged<String> onChange;

  LoginInputWeiget(this.text,
      {this.leftText,
      this.leftAssets,
      this.width,
      this.flex,
      this.radius,
      this.height,
      this.hintText,
      this.type = LInputType.TEXT,
      this.maxLength,
      required this.onChange,
      Key? key})
      : super(key: key);

  @override
  _LoginInputPageState createState() => _LoginInputPageState(text);
}

class _LoginInputPageState extends State<LoginInputWeiget> {
  bool isPwdHide = false;

  _LoginInputPageState(this.text);

  String text = "";

  @override
  void initState() {
    super.initState();
    if (widget.type == LInputType.PASSWORD) isPwdHide = true;
  }

  @override
  Widget build(BuildContext context) {
    return LColumn.eazy([
      LRow(lStyle: boxStyle, children: [
        // LImage.easy(widget.leftAssets, 15.w, 20.w),
        // 3.lsw,
        // LText(widget.leftText, lStyle: leftStyle),
        // 7.lsw,
        // LContainer(
        //     lStyle: LStyle(
        //         width: 1,
        //         height: 14.w,
        //         backgroundColor: const Color(0x40999999))),
        7.lsw,
        Expanded(
            child: LInput(
          text,
          lInputType: widget.type,
          lStyle: LStyle(
              alignment: Alignment.center,
              fontWeight: FontWeight.w400,
              height:52.w,
              fontSize: 14.sp,
              hintText: widget.hintText,
              hintColor: AppColors.textHintColor,
              obscureText: isPwdHide,
              maxLength: widget.maxLength),
          onChanged: (text) {
            this.text = text;
            widget.onChange(text);
          },
        )),
      ]),
      // LDivider(1.w, 0xFFEAEAEA.color)
    ]);
  }

  @override
  void dispose() {
    super.dispose();
  }

  get boxStyle => LStyle(
        css: '''
      padding:0 12px;
      width: 317px;
      height: 52px;
      background: #F4F5F7;
      border-radius: 26px 26px 26px 26px;
      ''',
      );

  get leftStyle => LStyle(
        // padding: EdgeInsets.only(top: 2.w),
        css: ''' font-weight: 400;
font-size: 15px;
color: #333333;''',
      );
}
